home *** CD-ROM | disk | FTP | other *** search
- #define debug 0
- /*
- TOWNS囲碁棋譜記録プログラム
- 1993/07/25 久保田俊也
-
- 93/07/25 banデ-タの親グル-プのセルを操作する関数の集まり
-
-
- */
- #include <stdlib.h>
- #include "igo.h"
- #include "banx.h"
-
- static GCELL *gcell=NULL;
- static GCELL *free_p;
-
- int gcell_init()
- {
- int i;
-
- if(gcell == NULL){
- gcell = (GCELL *)my_malloc( sizeof(GCELL) * MAX_BANSIZE2);
- if( gcell == NULL){
- return -1;
- }
- }
-
- for(i=0;i<MAX_BANSIZE2-1;i++){
- gcell[i].next = &gcell[i+1];
- gcell[i].iro = FREE_CELL; /* free_cell の意味で使っている */
- gcell[i].dame_ptr = NULL;
- gcell[i].territory_iro = BLANK;
- gcell[i].henkan_territory_iro = BLANK;
- gcell[i].dame_number = 0;
- }
- gcell[MAX_BANSIZE2-1].next = NULL;
- gcell[MAX_BANSIZE2-1].iro = FREE_CELL; /* free_cell の意味で使っている */
- gcell[MAX_BANSIZE2-1].dame_ptr = NULL;
- gcell[MAX_BANSIZE2-1].territory_iro = BLANK;
- gcell[MAX_BANSIZE2-1].henkan_territory_iro = BLANK;
- gcell[MAX_BANSIZE2-1].dame_number = 0;
-
- free_p = &gcell[0];
- return 0;
-
- }
-
- int gcell_end()
- {
-
- if(gcell == NULL){
- return -1;
- }else{
- my_free(gcell);
- return 0;
- }
-
- }
-
- GCELL *gcell_get()
- {
- GCELL *wk_te;
-
- if(free_p == NULL){
- return NULL;
- }else{
- wk_te = free_p;
- free_p = free_p->next;
- return wk_te;
- }
-
- }
-
- int gcell_free(GCELL *p)
- {
-
- p->next = free_p;
- p->iro = FREE_CELL;
- free_p = p;
- return 0;
- }
-
-